home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / infoserv / www / cern / doc / www-talk.archive.Z / www-talk.archive / text0392.txt < prev    next >
Encoding:
Text File  |  1992-11-30  |  1.7 KB  |  61 lines

  1. /*
  2. Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  3.  
  4. Permission to use, copy, modify, and distribute this material 
  5. for any purpose and without fee is hereby granted, provided 
  6. that the above copyright notice and this permission notice 
  7. appear in all copies, and that the name of Bellcore not be 
  8. used in advertising or publicity pertaining to this 
  9. material without the specific, prior written permission 
  10. of an authorized representative of Bellcore.  BELLCORE 
  11. MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  12. OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  13. WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  14. */
  15. #include <stdio.h>
  16.  
  17. #define BASE64 1
  18. #define QP 2 /* quoted-printable */
  19.  
  20. main(argc, argv)
  21. int argc;
  22. char **argv;
  23. {
  24.     int encode = 1, which = BASE64, i;
  25.     FILE *fp = stdin;
  26.  
  27.     for (i=1; i<argc; ++i) {
  28.         if (argv[i][0] == '-') {
  29.             switch (argv[i][1]) {
  30.                 case 'u':
  31.                     encode = 0;
  32.                     break;
  33.                 case 'q':
  34.                     which = QP;
  35.                     break;
  36.                 case 'b':
  37.                     which = BASE64;
  38.                     break;
  39.         default:
  40.                     fprintf(stderr,
  41.                        "Usage: mmencode [-u] [-q] [-b] [file name]\n");
  42.                     exit(-1);
  43.             }
  44.         } else {
  45.             fp = fopen(argv[i], "r");
  46.             if (!fp) {
  47.                 perror(argv[i]);
  48.                 exit(-1);
  49.             }
  50.         }
  51.     }
  52.     if (which == BASE64) {
  53.         if (encode) to64(fp, stdout); else from64(fp, stdout, NULL, 0);
  54.     } else {
  55.         if (encode) toqp(fp, stdout); else fromqp(fp, stdout, NULL, 0);
  56.     }
  57.     return(0);
  58. }
  59.  
  60.  
  61.